<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
留言：<input type="text" value="" maxlength="15" onkeyup="Length(this, 15, 'length');">

<span class="red" id="length">15/15</span>
<script>
    function Length(obj, maxlength, id) {
        // 函数，3个参数，表单名字 限制字符 表单域元素名
        var rem = maxlength - obj.value.length;
        var wid = id;
        if (rem < 0) {
            rem = 0;
        }
        document.getElementById(wid).innerHTML = +rem + '/' + "15";
    }
</script>

</html>